package Exam3;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;

public class Test1 {
    public static void main(String[] args) {
        String info = "10001,张无忌,男,2023-07-22 11:11:12,东湖-黄鹤楼#10002,赵敏,女,2023-07-22 09:11:21,黄鹤楼-归元禅寺#10003,周芷若,女,2023-07-22 04:11:21,木兰文化区-东湖#10004,小昭,女,2023-07-22 08:11:21,东湖#10005,灭绝,女,2023-07-22 17:11:21,归元禅寺";
        String[] infos = info.split("#");
        try {
            List<Student> list = new ArrayList<>();
            for (String s : infos) {
                System.out.println(s);
                String[] ss = s.split(",");
                DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

                // 转换字符串为LocalDateTime
                LocalDateTime localDateTime = LocalDateTime.parse(ss[3], formatter);
                Student student = new Student(Long.parseLong(ss[0]), ss[1], ss[2], localDateTime, ss[4]);
                list.add(student);
            }
//        for(Student student:list){
//            System.out.println(student.toString());
//        }
            count(list);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public static void count(List<Student> list){
        int count1=0,count2=0,count3=0,count4=0;
        for(Student student:list){
            String[]placers=student.getPlacer().split("-");
            if(placers.length>=1) {
                switch (placers[0]) {
                    case "东湖":
                        count1++;
                        break;
                    case "黄鹤楼":
                        count2++;
                        break;
                    case "木兰文化区":
                        count3++;
                        break;
                    case "归元禅寺":
                        count4++;
                        break;
                }
            }
            if(placers.length>=2) {
                switch (placers[1]) {
                    case "东湖":
                        count1++;
                        break;
                    case "黄鹤楼":
                        count2++;
                        break;
                    case "木兰文化区":
                        count3++;
                        break;
                    case "归元禅寺":
                        count4++;
                        break;
                }
            }
        }
        System.out.println("东湖:"+count1);
        System.out.println("黄鹤楼:"+count2);
        System.out.println("木兰文化区:"+count3);
        System.out.println("归元禅寺:"+count4);
    }
}
